local fs  = require "nixio.fs"
local sys = require "luci.sys"

local o
m = Map("Set_Modem_Type", translate("Set Modem Type"))--config file

function sleep(n)
   os.execute("sleep " .. n)
end


s=m:section(TypedSection, "modem_type",translate("Modem Type"))-- "Modem_Type"
s.anonymous=true
s.addremove = false

s:tab("modem_type",translate("Modem Base Config"))
s:tab("openamip",translate("OpenAMIP Config"))
s:tab("gis",translate("GIS Config"))


o=s:taboption("modem_type",ListValue,"Modem_Type",translate("MODEM TYPE"))
o:value("6",translate("Newtec MDM2510"))
o:value("5",translate("Gilat SkyEdge II"))
o:value("4",translate("iQ 200"))
o:value("3",translate("iDirect MODEM X7"))
o:value("2",translate("iDirect MODEM X5"))
o:value("1",translate("UHP MODEM"))
o:value("0",translate("OFF"))

o=s:taboption("modem_type",Value, "iDirect_server_ip", translate("TELNET:SERVER IP"),translate("SERVER IP,such as 172.28.34.121"))
o:depends({Modem_Type="2"})
o=s:taboption("modem_type",Value, "iDirect_client_ip", translate("TELNET:CLIENT IP"),translate("CLIENT IP,such as 172.28.34.124"))
o:depends({Modem_Type="2"})
o=s:taboption("modem_type",Value, "iDirect_client_netmask", translate("TELNET:CLIENT NETMASK"),translate("NETMASK,such as 255.255.255.248"))
o:depends({Modem_Type="2"})
o=s:taboption("modem_type",Value, "iDirect_username", translate("TELNET:USERNAME"),translate("Username for login telnet,such as admin"))
o:depends({Modem_Type="2"})
o=s:taboption("modem_type",Value, "iDirect_password", translate("TELNET:PASSWORD"),translate("Password for login telnet,such as P@55w0rd!"))
o:depends({Modem_Type="2"})

o=s:taboption("modem_type",ListValue, "iDirectX7_system", translate("X7 SYSTEM TYPE"),translate("Evolution or Velocity"))
o:depends({Modem_Type="3"})
o:value("2",translate("Velocity"))
o:value("1",translate("Evolution"))
o=s:taboption("modem_type",Value, "iDirectX7_server_ip", translate("SSH:SERVER IP"),translate("SERVER IP,such as 172.28.34.121"))
o:depends({Modem_Type="3"})
o=s:taboption("modem_type",Value, "iDirectX7_client_ip", translate("SSH:CLIENT IP"),translate("CLIENT IP,such as 172.28.34.124"))
o:depends({Modem_Type="3"})
o=s:taboption("modem_type",Value, "iDirectX7_client_netmask", translate("SSH:CLIENT NETMASK"),translate("NETMASK,such as 255.255.255.248"))
o:depends({Modem_Type="3"})
o=s:taboption("modem_type",Value, "iDirectX7_ssh_username", translate("SSH:USERNAME"),translate("Username for login SSH,such as root"))
o:depends({Modem_Type="3"})
o=s:taboption("modem_type",Value, "iDirectX7_ssh_password", translate("SSH:PASSWORD"),translate("Password for login SSH,such as iDirect"))
o:depends({Modem_Type="3"})
o=s:taboption("modem_type",Value, "iDirectX7_username", translate("TELNET:USERNAME"),translate("Username for login telnet,such as admin"))
o:depends({Modem_Type="3"})
o=s:taboption("modem_type",Value, "iDirectX7_password", translate("TELNET:PASSWORD"),translate("Password for login telnet,such as P@55w0rd!"))
o:depends({Modem_Type="3"})

o=s:taboption("modem_type",Value, "iQ200_server_ip", translate("SSH:SERVER IP"),translate("SERVER IP,such as 172.28.34.121"))
o:depends({Modem_Type="4"})
o=s:taboption("modem_type",Value, "iQ200_client_ip", translate("SSH:CLIENT IP"),translate("CLIENT IP,such as 172.28.34.124"))
o:depends({Modem_Type="4"})
o=s:taboption("modem_type",Value, "iQ200_client_netmask", translate("SSH:CLIENT NETMASK"),translate("NETMASK,such as 255.255.255.248"))
o:depends({Modem_Type="4"})
o=s:taboption("modem_type",Value, "iQ200_ssh_username", translate("SSH:USERNAME"),translate("Username for login SSH,such as root"))
o:depends({Modem_Type="4"})
o=s:taboption("modem_type",Value, "iQ200_ssh_password", translate("SSH:PASSWORD"),translate("Password for login SSH,such as iDirect"))
o:depends({Modem_Type="4"})

o=s:taboption("modem_type",Value, "GilatSkyEdgeII_Server_IP", translate("Server IP"),translate("GilatSkyEdgeII Modem IP"))
o:depends({Modem_Type="5"})
o=s:taboption("modem_type",Value, "GilatSkyEdgeII_Client_IP", translate("Client IP"),translate("The same network segment as the modem"))
o:depends({Modem_Type="5"})

o=s:taboption("modem_type",Value, "NewtecMDM2510_Server_IP", translate("Server IP"),translate("Newtec MD2510 Modem IP"))
o:depends({Modem_Type="6"})
o=s:taboption("modem_type",Value, "NewtecMDM2510_Client_IP", translate("Client IP"),translate("The same network segment as the modem"))
o:depends({Modem_Type="6"})

o=s:taboption("modem_type",Value, "UHP_server_ip", translate("SNMP:SERVER IP"),translate("SERVER IP,such as 192.168.222.1"))
o:depends({Modem_Type="1"})
o=s:taboption("modem_type",Value, "UHP_server_port", translate("SNMP:SERVER PORT"),translate("SERVER PORT,such as 161"))
o:depends({Modem_Type="1"})
o=s:taboption("modem_type",Value, "UHP_client_ip", translate("SNMP:CLIENT IP"),translate("CLIENT IP,such as 192.168.222.5"))
o:depends({Modem_Type="1"})


o=s:taboption("modem_type",Value, "UHP_client_port", translate("SNMP:CLIENT PORT"),translate("CLINET PORT,such as 162"))
o:depends({Modem_Type="1"})
o=s:taboption("modem_type",Value, "UHP_client_netmask", translate("UHP:CLIENT NETMASK"),translate("NETMASK,such as 255.255.255.0"))
o:depends({Modem_Type="1"})



o=s:taboption("openamip",ListValue,"OpenAMIP_Enable",translate("OpenAMIP ENABLE"))
o:value("2",translate("COMPLETE MODE"))
o:value("1",translate("SIMPLE MODE"))
o:value("0",translate("OFF"))

o=s:taboption("openamip",Value, "Openamip_ip", translate("OpenAMIP SERVER IP"),translate("OPENAMIP IP,such as 172.28.34.122"))
o:depends({OpenAMIP_Enable="1"})
o:depends({OpenAMIP_Enable="2"})
o=s:taboption("openamip",Value, "Openamip_port", translate("OpenAMIP SERVER PORT"),translate("OPENAMIP PORT,such as 4001"))
o:depends({OpenAMIP_Enable="1"})
o:depends({OpenAMIP_Enable="2"})
o=s:taboption("openamip",Value, "Openamip_netmask", translate("OpenAMIP NETMASK"),translate("NETMASK,such as 255.255.255.248"))
o:depends({OpenAMIP_Enable="1"})
o:depends({OpenAMIP_Enable="2"})
o=s:taboption("openamip",Value, "BANDWIDTH", translate("CARRIER BANDWIDTH"), translate("MHz. NOT RECOMMENDED TO MODIFY"))
o.default="20000"
o:depends({OpenAMIP_Enable="2"})
o=s:taboption("openamip",Value, "ANTENNA_LOSTTIME", translate("ANTENNA LOSTTIME"), translate("ms. NOT RECOMMENDED TO MODIFY"))
o.default="15000"
o:depends({OpenAMIP_Enable="2"})
o=s:taboption("openamip",ListValue, "TRACK_MODE", translate("TRACKING MODE"), translate("NOT RECOMMENDED TO MODIFY"))
o.default="0"
o:value("0",translate("DVB MODE"))
o:value("1",translate("BEACON MODE"))
o:value("2",translate("NARROW MODE"))
o:depends({OpenAMIP_Enable="2"})

o=s:taboption("openamip",Value, "MULTI_AXIS", translate("MULTIAXIS TRACKING"), translate("NOT RECOMMENDED TO MODIFY"))
o.default="2"
o:value("2",translate("2 AXIS"))
o:value("3",translate("3 AXIS"))
o:depends({OpenAMIP_Enable="2"})


o=s:taboption("openamip",ListValue,"LNB_SWITCH_MODE",translate("LNB SWITCH MODE"),  translate("LNB SWITCH MODE: SINGLE, VOLTAGE, 22K"))
o:value("0",translate("SINGLE"))
o:value("1",translate("VOLTAGE"))
o:value("2",translate("22K"))
o:depends({OpenAMIP_Enable="2"})
o=s:taboption("openamip",Value,"22K_ON",translate("22K ON"),  translate("RX LO: MHz"))
o:depends({LNB_SWITCH_MODE="2"})
o.default="9750"
o=s:taboption("openamip",Value,"22K_OFF",translate("22K OFF"),  translate("RX LO: MHz"))
o:depends({LNB_SWITCH_MODE="2"})
o.default="10600"
o=s:taboption("openamip",Value,"13V",translate("13V"),  translate("RX LO: MHz"))
o:depends({LNB_SWITCH_MODE="1"})
o.default="9750"
o=s:taboption("openamip",Value,"18V",translate("18V"),  translate("RX LO: MHz"))
o:depends({LNB_SWITCH_MODE="1"})
o.default="10600"

o=s:taboption("openamip",ListValue,"ROLL_OFF",translate("ROLL OFF"),  translate("CHECK YOU BW AND SR IS RIGHT. SR = BW/(1 + ROLL_OFF)"))
o:value("4",translate("20%"))
o:value("3",translate("15%"))
o:value("2",translate("10%"))
o:value("1",translate("5%"))
o:value("0",translate("AUTO"))
o.default="0"
o:depends({OpenAMIP_Enable="2"})

o=s:taboption("openamip",Flag, "WebSwitch_Enable", translate("DISABLE ABS FUNCTION"),nil)
o:depends({OpenAMIP_Enable="1"})
o:depends({OpenAMIP_Enable="2"})

o=s:taboption("gis",ListValue,"GIS_Enable",translate("GIS ENABLE"))
o:value("1",translate("ON"))
o:value("0",translate("OFF"))

o=s:taboption("gis",Value, "GIS_server_ip", translate("GIS SERVER IP"),translate("GIS IP,such as 10.0.0.195"))
o:depends({GIS_Enable="1"})
o=s:taboption("gis",Value, "GIS_server_port", translate("GIS SERVER PORT"),translate("GIS PORT,such as 7001"))
o:depends({GIS_Enable="1"})
o=s:taboption("gis",Value, "GIS_interval", translate("GIS INTERVAL"),translate("GIS UPDATE INTERVAL"))
o:depends({GIS_Enable="1"})



return m
